At present, increasing attention is paid to quality of audio in communication transmission, so it is required that, during coding and decoding, music quality be improved as far as possible on a premise of ensured quality of voice. Because information of a music signal is abundant, a code-excited linear prediction (CELP) coding mode for conventional voice cannot be used, and a transform coding method is usually used to process the music signal in a frequency domain, to improve coding quality of the music signal. However, it has now become a main subject of research on audio coding how to effectively use limited coding bits to encode information efficiently.
In current audio coding technologies, usually fast Fourier transform (FFT) or modified discrete cosine transform (MDCT) is used to transform a time domain signal to a frequency domain signal, and then the frequency domain signal is encoded. Usually, in transform coding, band division is performed on frequency domain coefficients, a normalized energy value of each band is obtained, intra-band coefficient energy values are normalized, and then bit allocation is performed, and finally intra-band coefficients are quantized according to bits that are allocated to each band, where bit allocation is a critical part. Bit allocation refers to, during a process of quantizing a frequency spectrum coefficient, bits that are of an audio signal and used to quantize the frequency spectrum coefficient are allocated to sub-bands according to sub-band features of a frequency spectrum.
An existing bit allocation process includes performing band division for frequency spectrum signals, for example, gradually increasing a bandwidth from a low frequency to a high frequency according to a critical frequency band theory; dividing a frequency spectrum into sub-bands, obtaining a normalized energy norm of each sub-band, and quantizing norm to obtain a sub-band normalization factor (wnorm); sorting the sub-bands in descending order according to values of their wnorms; and performing bit allocation, for example, allocating the number of bits iteratively for each sub-band according to the value of the wnorm. The iterative bit allocation may further be divided into the following steps: step 1—initializing the number of bits of each sub-band and an iteration factor (fac); step 2—finding a band corresponding to a greatest wnorm; step 3—adding a bandwidth value to the number of bits allocated to this band, and subtracting the fac from a value of the wnorm; and step 4—repeating step 2 and step 3 until all bits are allocated. It can be seen that, in the prior art, a smallest unit of bits allocated each time is the bandwidth value, while the smallest number of bits needed during quantization is less than the bandwidth value, which results in low efficiency of such integral bit allocation when a bit rate is low, where many bands are allocated no bits, and other bands are allocated too many bits. Because bits are allocated iteratively in a full frequency band, iteration parameters are the same for sub-bands with different bandwidths, which results in a random allocation result, relatively scattered quantization, and discontinuity between a previous frame and a next frame.
It can be learned that, when a bit rate is low, bit allocation greatly affects performance. Usually, bit allocation is mainly performed in a full frequency band according to a magnitude of a normalized energy of each sub-band, and when a bit rate is low, such allocation is random and also relatively scattered, which causes a phenomenon of discontinuous quantization in a time domain.